<?php
/**
 * Created by PhpStorm.
 * User: kb130
 * Date: 2017/10/16
 * Time: 10:16
 */

namespace util\validate\rules;

/**
 * 验证手机或者固定电话都可以通过验证
 * Class TelOrMobile
 * @package validate\rules
 */
class TelOrMobile extends BaseRule
{

    public function verify()
    {
        $telMatch = '/^(0[0-9]{2,3}-)?([2-9][0-9]{6,7})+(-[0-9]{1,4})?$/';
        $mobileMath = '/^1[3456789]{1}\d{9}$/';

        return preg_match($telMatch, $this->value) || preg_match($mobileMath, $this->value);
    }
}